package javabase.schoolwork.day6_19;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author fance
 * @date 2018/6/19 20:06
 */
public class Sum {
    public static void main(String[] args) throws IOException {
       /* InetAddress local = InetAddress.getLocalHost();
        InetAddress remote = InetAddress.getByName("www.baidu.com");

        System.out.println(local.getHostAddress());
        System.out.println(remote.getHostAddress());
        System.out.println(local.isReachable(5000));*/


      /*  URL url = new URL("http","www.cxjava.cn",
                80,"/curriculum.htm");

        InputStream inputStream = url.openStream();
        Scanner scanner = new Scanner(inputStream);
        scanner.useDelimiter("\n");
        while (scanner.hasNext()) {
            System.out.println(scanner.next());
        }*/


        /*URL url = new URL("http://www.myweb.com/download");

        System.out.println(url.getProtocol());
        System.out.println(url.getPort());
        System.out.println(url.getHost());
        System.out.println(url.getFile());
        System.out.println(url.toExternalForm());*/

       /* URL url = new URL("http://www.cxjava.cn");
        URLConnection urlConnection = url.openConnection();

        System.out.println(urlConnection.getContentLength());
        System.out.println(urlConnection.getContentType());
        System.out.println(new Date(urlConnection.getDate()));
        System.out.println(new Date(urlConnection.getLastModified()));
*/

      /* String key = "方斯";
      // String encod = URLEncoder.encode(key,"UTF-8");
        System.out.println(key);
       // String dencod = URLEncoder.encode(encod,"UTF-8");
       // System.out.println(dencod);*/


        /*ServerSocket server = new ServerSocket(8888);
        Socket socket = server.accept();
        PrintStream out = new PrintStream(socket.getOutputStream());
        String s = "hello ";
        out.println(s);

        out.close();
        socket.close();
        server.close();*/

        ServerSocket server = new ServerSocket(8888);
        Socket socket = server.accept();
        boolean flag = true;
        while (flag) {
            Socket client = server.accept();
            ThreadServer threadServer = new ThreadServer();
            threadServer.setClient(client);
            threadServer.start();
        }
        server.close();
    }
}
